package com.suse.springmvcdemo;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;


@RestController
public class UserController {
    @RequestMapping("/hello")
    public String param1(String name) {
        return "hello";
    }

    @RequestMapping("/hello2")
    public String param2(String name,Integer age) {
        return "name:"+name+",age:"+age;
    }

    @RequestMapping("/param3")
    public String param3(MultipartFile file) throws IOException {
//        System.out.println(file.getName());
        file.transferTo(new File("C:/temp/"+file.getOriginalFilename()));
        return "接收到文件"+file.getOriginalFilename();
    }
}
